﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using WebApiDemo.Services;

namespace WebApiDemo.Controllers
{
    /// <summary>
    /// 世界区域
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class RegionController : ControllerBase
    {
        private readonly IAreaSerivce _areaSerivce;

       /// <summary>
       /// 构造函数
       /// </summary>
       /// <param name="areaSerivce"></param>
        public RegionController(IAreaSerivce areaSerivce)
        {
            _areaSerivce = areaSerivce;
        }

        /// <summary>
        /// 查询所有国家区域列表
        /// </summary>
        /// <param name="langType"></param>
        /// <returns></returns>
        [HttpGet("GetAllCountry")]
        [ProducesResponseType(typeof(IList<Area>), StatusCodes.Status200OK)]
        public IList<Area> GetAllCountry(string langType = "zh_CN")
        {
            return _areaSerivce.GetAllCountry(langType);
        }

        /// <summary>
        /// 查询指定区域对应层级列表信息
        /// </summary>
        /// <param name="areaId"></param>
        /// <param name="level"></param>
        /// <param name="langType"></param>
        /// <returns></returns>
        [HttpPost("SelectAreaList")]
        [ProducesResponseType(typeof(IList<Area>), StatusCodes.Status200OK)]
        public IList<Area> SelectAreaList([FromForm]string areaId, [FromForm]int? level, [FromForm]string langType = "zh_CN")
        {
            return _areaSerivce.SelectAreaList(areaId, level, langType);
        }    
    }
}
